﻿using System;
using System.Data;
using System.IO;
using System.Collections.Generic;

using We.Moonlight.ViItem;
using We.Moonlight.MSql;

namespace We.Moonlight.ViDesk
{
    public class PassiveDesk
    {
        private int id;
        private string name;
        private FileInfo icon;
        private FileInfo BackgroundImage;

        public int ID
        {
            get { return id; }
        }



        public PassiveDesk(mDB.DesksRow DR)
        {
            id = DR.ID;

            name = DR.Name;

            try { icon = new FileInfo(DR.IconPath); }
            catch (StrongTypingException) { icon = null; }

            try { BackgroundImage = new FileInfo(DR.BackgroundPath); }
            catch (StrongTypingException) { BackgroundImage = null; }

        }
        public PassiveDesk(int Identification)
        {
            id = Identification;
        }
        public FileInfo Icon
        {
            get { return icon; }
            set { icon = value; }
        }

        public FileInfo Background
        {
            get { return BackgroundImage; }
            set { BackgroundImage = value; }
        }

        public String Name
        {
            get { return name; }
            set { name = value; }
        }

        public ActiveDesk Activate()
        {
            ActiveDesk D = new ActiveDesk(this);

            List<IVi> LVI = SqlViItem.SelectDesk(D.ID);
            if(LVI != null)
                foreach (IVi Doc in LVI)
                    D.Documents.Add(Doc);
            return D;
        }
    }
}